package com.j4dream.property.javabasic.designpattern.factory_abstract;

public class FactoryProducer {
    public static AbstractFactory getFactory(String factory) {
        if ("shape".equalsIgnoreCase(factory)) {
            return new ShapeFactory();
        } else if ("color".equalsIgnoreCase(factory)) {
            return new ColorFactory();
        }
        return null;
    }

    public static void main(String[] args) {
        AbstractFactory shapeFactory = FactoryProducer.getFactory("shape");
        shapeFactory.getShape("circle").draw();

        AbstractFactory colorFactory = FactoryProducer.getFactory("color");
        colorFactory.getColor("red").fill();
    }
}
